package com.joelaws.prototype.client.service;

import com.gwtext.client.widgets.HTMLPanel;
import com.gwtext.client.widgets.Panel;
import com.gwtext.client.widgets.TabPanel;
import com.gwtext.client.widgets.layout.FitLayout;
import com.joelaws.prototype.client.CenterPanel;
import com.joelaws.prototype.client.data.User;

public class ServicePanel extends CenterPanel {

	final private User user;

	public ServicePanel(User user) {
		this.user = user;
		setBorder(false);
		setFrame(true);
		setLayout(new FitLayout());
		if (user == null) {
			add(new HTMLPanel("Please login"));
		} else {
			add(getViewPanel());
		}
	}

	public Panel getViewPanel() {

		TabPanel tabPanel = new TabPanel();
		tabPanel.setFrame(true);
		tabPanel.setActiveTab(0);

		tabPanel.add(new HomeTab(user));

		if (user.getDatingService() != null) {
			tabPanel.add(new DatingTab(user));
		}

		if (user.getMessagingService() != null) {
			tabPanel.add(new MessagingTab(user));
		}

		if (user.getNetworkingService() != null) {
			tabPanel.add(new NetworkingTab(user));
		}
		return tabPanel;
	}

	public String getName() {
		return "service";
	}

}
